<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>订单列表</title>
    <#--<meta http-equiv="refresh" content="30">-->

    <!-- Le styles -->
    <link href="/common/js/bootstrap-3.0.0/css/bootstrap-united.min.css" rel="stylesheet">
    <style type="text/css">
        body {
            padding: 10px 0;
        }
    </style>
</head>
<body>
<#--<div class="container">-->

    <form id="form" method="post" class="well form-horizontal">
        <fieldset>
            <legend>订单列表</legend>
            <div class="form-group">
                <div class="col-md-6">
                    <label class="col-md-4 control-label" for="userName">商家手机号</label>

                    <div class="col-md-8">
                        <input id="mobile" name="mobile" type="text" class="form-control"/>
                    </div>
                </div>

                <div class="col-md-6">
                    <label class="col-md-4 control-label" for="roleName">订单状态</label>

                    <div class="col-md-8">

                        <select id="status" name="status" class="form-control">
                            <option value=""></option>
                        <#if statusList??>
                            <#list statusList as status>
                                <option value="${status.getCode()?string}">${status.getName()}</option>
                            </#list>
                        </#if>
                        </select>
                    </div>
                </div>

                <div class="col-md-6">
                    <label class="col-md-4 control-label" for="roleName">支付状态</label>

                    <div class="col-md-8">

                        <select id="pay_status" name="pay_status" class="form-control">
                            <option value=""></option>
                        <#if payStatusList??>
                            <#list payStatusList as status>
                                <option value="${status.getCode()?string}">${status.getName()}</option>
                            </#list>
                        </#if>
                        </select>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-12 text-right">
                    <button type="button" id="searchBtn" style="width: 80px;" class="btn btn-primary">查询</button>
                </div>
            </div>
        </fieldset>
    </form>

    <div class="col-md-12 text-right" style="margin:10px 0;">
        <#--<a style="width: 80px;" href="/msg/addPushMsgView" class="btn btn-success">新建推送</a>-->
    </div>

    <table id="resultTable" class="table table-bordered table-hover">
        <thead>
        <tr>
            <th>编号</th>
            <th>顾客</th>
            <th>顾客手机</th>
            <th>商家</th>
            <th>商家手机</th>
            <th>商家职业</th>
            <th>支付方式</th>
            <th>总金额(元)</th>
            <#--<th>代金券抵扣</th>-->
            <#--<th>博币抵扣</th>-->
            <th>定金(元)</th>
            <#--<th>实际支付金额</th>-->
            <th>订单状态</th>
            <th>付款状态</th>
            <th>下单时间</th>
            <th>顾客备注</th>
            <th>详情</th>
        </tr>
        </thead>
        <tbody>
        <script type="text/html">
            <tr>
                <td>{{id}}</td>
                <td>{{user.cnName!''}}</td>
                <td>{{user.mobile!''}}</td>
                <td>{{bizUser.cnName!''}}</td>
                <td>{{bizUser.mobile!''}}</td>
                <td>{{bizUser.bizWork.name!''}}</td>
                <td>{{payType?renderPayType}}</td>
                <td>{{price}}</td>
                <#--<td>{{voucher}}</td>-->
                <#--<td>{{coins}}</td>-->
                <td>{{deposit}}</td>
                <#--<td>0</td>-->
                <td>{{status?renderOrderStatus}}</td>
                <td>{{payStatus?renderOrderPayStatus}}</td>
                <td>{{createTime?parseDate}}</td>
                <td>{{descn!''}}</td>
                <td>{{_self_data?renderOperation}}</td>
            </tr>
        </script>
        </tbody>
    </table>
<#--</div>-->
<script type="text/javascript" src="/common/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="/common/js/bootstrap-table.20130913.js"></script>
<script type="text/javascript" src="/common/js/dateformat.js"></script>
<script type="text/javascript" src="/common/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
    $(function () {
        var param = $("#form").serialize();
        var s = $("#resultTable").bsTable({
            url: '/order/getOrderList.json',
            ajaxType: "POST",  //ajax 提交方式 post 或者 get
            pageNo: 1,
            pageNoAlias: 'page',
            pageSize: 50,
            pageSizeAlias: 'pageSize',
            pagingAlign: "right",
            param: param,
            countRoot: "total",
            dataRoot: "list"
        });

        $("#searchBtn").on('click', function () {
            var param = $("#form").serialize();
            s.reload(param);
        });

//        window.onresize = function () {
//            window.top.autoIFrame();
//        }
    });

    function renderOrderStatus(status) {
        if (status == -1) {
            return "待审核";
        } else if(status == 1) {
            return "审核通过,待接单";
        } else if(status == 2) {
            return "商家接单";
        } else if(status == 3) {
            return "订单取消";
        }else if(status == 4) {
            return "订单取消已退款";
        }else if(status == 5) {
            return "商家完成订单";
        }else if(status == 6) {
            return "用户确认完成订单";
        }else{
            return "未知状态";
        }
    }

    function renderPayType(payType) {
        if (payType == 1) {
            return "支付宝";
        } else if(payType == 2) {
            return "微信支付";
        }else{
            return "其他";
        }
    }

    function renderOrderPayStatus(payStatus) {
        if (payStatus == -1) {
            return "未付款";
        } else if(payStatus == 1) {
            return "已付定金,未付尾款";
        }else if(payStatus == 2) {
            return "已付定金和尾款";
        }else{
            return "未知状态";
        }
    }

    function renderOperation(row) {
        if (row){
            if (row.status == -1) {
                if (row.bizUser.bizWorkType == 1){
                    return '<a style="width: 80px;margin: 3px 1px;" href="/order/orderAdminChangeStatus?order_id='+row.id+'&status=1" class="btn btn-info">客服确认</a>' +
                            '<a style="width: 80px;margin: 3px 0;" href="/order/orderDetailManage?order_id='+row.id+'" class="btn btn-success">查看详情</a>';
                }else{
                    return '<a style="width: 80px;margin: 3px 0;" href="/order/orderDetailManage?order_id='+row.id+'" class="btn btn-success">查看详情</a>';
                }

            }else{
                return '<a style="width: 80px;margin: 3px 0;" href="/order/orderDetailManage?order_id='+row.id+'" class="btn btn-success">查看详情</a>';
            }
        }else{
            return ""
        }

    }

//
////    <td>
////    <a style="width: 80px;margin: 3px 0;" href="/order/orderChangeStatus?order_id=&status=1" class="btn btn-info">客服确认</a>
////            <a style="width: 80px;margin: 3px 0;" href="/order/orderChangeStatus?order_id=status=2" class="btn btn-info">商家接单</a>
////            <a style="width: 80px;margin: 3px 0;" href="/order/orderChangeStatus?order_id=status=3" class="btn btn-info">取消订单</a>
////            <a style="width: 80px;margin: 3px 0;" href="/order/orderDetailManage?order_id={{id}}" class="btn btn-success">查看详情</a></td>


</script>
</body>
</html>